package com.eddie.controller;

import com.eddie.domain.User;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView;

/**
 * ClassName:TestController
 * Package:com.eddie.controller
 * Description:
 *
 * @date:2020/4/19 0019 23:05
 * @author:1164259132@qq.com
 */
@Controller
@RequestMapping("/test")
public class TestController {

    @RequestMapping("/controller")
    public String testController(Model model) {
        model.addAttribute("message", "ControllerTest 应用Web项目");
        return "controller";
    }

    @RequestMapping("/model")
    public String testModel(Model model, ModelMap modelMap) {
        User user01 = new User();
        user01.setUsername("章三三");
        user01.setPassword("123456");
        user01.setTel("110119120");
        model.addAttribute("user01", user01);

        User user02 = new User();
        user02.setUsername("里斯");
        modelMap.addAttribute("user02", user02);

        return "model";
    }

    @RequestMapping("/modelandview")
    public ModelAndView testModelAndView(ModelAndView mv) {
        User user01 = new User();
        user01.setUsername("章三三");
        user01.setPassword("123456");
        user01.setTel("110119120");
        mv.addObject("user01", user01);
        mv.setViewName("mv");
        return mv;
    }

    @RequestMapping("/requestparam")
    public ModelAndView testRequestParam(@RequestParam(value = "username") String username, @RequestParam(name = "password") String password) {

    }
}
